package com.my.rabbitmq.five;

import com.my.utils.RabbitMQUtils;
import com.rabbitmq.client.Channel;

import java.util.Scanner;

/**
 * @author 林允
 * @version 1.0
 * @description: TODO
 * @date 2023/11/29 15:33
 */
// 发送消息
public class EmitLog {

    public static final String Exchange_NAME = "logs";

    public static void main(String[] args) throws Exception{
        Channel channel = RabbitMQUtils.getChannel();
        channel.exchangeDeclare(Exchange_NAME, "fanout");

        Scanner sc = new Scanner(System.in);

        while (sc.hasNext()){
            String message = sc.next();
            channel.basicPublish(Exchange_NAME, "", null, message.getBytes("UTF-8"));
            System.out.println("生产者发出消息" + message);
        }
    }

}
